export function payment(type, data) {
	return new Promise(function(resolve, reject) {
		if (type == 1) {
			uni.requestPayment({
				provider: 'wxpay',
				orderInfo: data,
				success: function(res) {
					console.log('success:' + JSON.stringify(res));
					resolve(res)
				},
				fail: function(err) {
					reject(err)
					console.log('fail:', err);
				}
			});
		} else {
			uni.requestPayment({
				provider: 'alipay',
				orderInfo: data,
				success: function(res) {
					console.log('success:' + JSON.stringify(res));
					resolve(res)
				},
				fail: function(err) {
					uni.showToast({
						title: err,
						icon: "none"
					})
					console.log('fail:' + JSON.stringify(err));
					reject(err)

				}
			});
			return
			const plug = uni.requireNativePlugin("Html5app-AlipayAuth");
			console.log(type, data, 'type,data', plug);
			//这里安卓使用 原生插件的支付宝支付，ios使用官方的支付
			switch (uni.getSystemInfoSync().platform) {
				case 'android':
					plug.Payment({
						"orderInfo": data
					}, ret => {
						uni.showToast({
							title: err,
							icon: "none"
						})
						console.log(ret, 'retretretretret')
						if (ret.code == 9000) {
							resolve(ret)
						} else {
							reject(ret)
						}

					});
					break;
				case 'ios':
					uni.requestPayment({
						provider: 'alipay',
						orderInfo: data,
						success: function(res) {
							console.log('success:' + JSON.stringify(res));
							resolve(res)
						},
						fail: function(err) {
							uni.showToast({
								title: err,
								icon: "none"
							})
							console.log('fail:' + JSON.stringify(err));
							reject(err)

						}
					});
				default:
					break;
			}

		}
	})
}
